package com.cq.hd.system.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.system.service.TbContentCategoryService;
import com.cq.hd.system.api.TbContentCategoryApi;
import com.cq.hd.system.api.dto.ContentCategoryPageDto;
import com.cq.hd.system.api.dto.ContentCategorySaveDto;
import com.cq.hd.system.api.dto.ContentCategoryUpdateDto;
import com.cq.hd.system.api.vo.ContentCategoryPageVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学院分类表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-19
 */
@RestController
public class TbContentCategoryController implements TbContentCategoryApi {

    @Autowired
    private TbContentCategoryService contentCategoryService;

    @ApiOperation(value = "学院分类列表")
    @ApiImplicitParam(name = "contentCategoryPageDto", value = "学院分类查询参数", required = true, paramType = "query", dataType = "ContentCategoryPageDto")
    @ApiResponse(response = ContentCategoryPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<ContentCategoryPageVo>> pageContentCategory(ContentCategoryPageDto contentCategoryPageDto) {
        contentCategoryPageDto.setOrderType(2);
        return ResultGenerator.success(contentCategoryService.pageContentCategory(contentCategoryPageDto));
    }

    @ApiOperation(value = "保存学院分类")
    @ApiImplicitParam(name = "contentCategorySaveDto", value = "学院分类保存参数", required = true, paramType = "body", dataType = "ContentCategorySaveDto")
    @Override
    public Result<Object> saveContentCategory(@RequestBody ContentCategorySaveDto contentCategorySaveDto) {
        return ResultGenerator.success(contentCategoryService.saveContentCategory(contentCategorySaveDto));
    }

    @ApiOperation(value = "更新学院分类")
    @ApiImplicitParam(name = "contentCategoryUpdateDto", value = "学院分类更新参数", required = true, paramType = "body", dataType = "ContentCategoryUpdateDto")
    @Override
    public Result<Boolean> updateContentCategory(@RequestBody ContentCategoryUpdateDto contentCategoryUpdateDto) {
        return ResultGenerator.success(contentCategoryService.updateContentCategory(contentCategoryUpdateDto));
    }

    @ApiOperation(value = "删除学院分类")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    @Override
    public Result<Boolean> deleteContentCategory(Long id) {
        return ResultGenerator.success(contentCategoryService.deleteContentCategory(id));
    }

}
